
package com.alex.goods.dao;

import com.alex.goods.entity.Goods;
import com.alex.goods.util.DBUtil;

import java.util.List;

public class GoodsDao {
	
	public List<Goods> selectGoodsList(String sql,Object... params) {
		return DBUtil.executeDQL(sql, Goods.class,params);
	}

	public void addGoods(Object ...params) {
		
		String sql = "insert into goods(goods_no,goods_name,standard,material,isin,isout) values(?,?,?,?,?,?)";
		
		for(int i=0;i<params.length;i++) {
			System.out.println(params[i]);
		}
		System.out.println(params[0]+"     "+params[1]);
		DBUtil.excuteDML(sql, params);
		
	}

	public Long getGoodsKindNum(String sqlcount) {
		// TODO Auto-generated method stub
		//String sql = "select count(1) from goods";
		return DBUtil.executeCount(sqlcount);
	}
     
	public void updateGoodsInOut(String id, String isin, String isout) {
	    String sql = "update goods set isin = ? ,isout=? where id=?";
		 DBUtil.excuteDML(sql, isin,isout,id);
	}

    public void updateGoodsToNotUse(String goodsNo) {
		String sql = " update goods set isuse = 'off'  where goods_no = ?  ";
		DBUtil.excuteDML(sql,goodsNo);
    }

	public void updateGoodsUse(String goodsNo) {
		String sql = " update goods set isuse = 'on' where goods_no = ?  ";
		DBUtil.excuteDML(sql,goodsNo);
	}
}
